#include "XFtpCWD.h"
#include "XFtpSession.h"
#include "LogWrapper.h"

XFtpCWD::XFtpCWD()
{
}


XFtpCWD::~XFtpCWD()
{
}

void XFtpCWD::parse(const std::string & type, const std::string & msg)
{
    std::string dir = mSesssion->getCurDir();
    if ((msg[0] != '/')) {
        if (dir[dir.size() - 1] != '/') {
            dir += "/";
        } 
        dir += msg + "/";
    } else if (msg[0] == '/'){
        dir = msg + "/";
    }
    
    LOG_DEBUG("change dir to {0}", dir);
    mSesssion->setCurDir(dir);
    responseFtpCmd("250 Directory succes chanaged.\r\n");
}
